package com.kingeid.test;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView mTvMessage;
    Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mTvMessage = findViewById(R.id.tvMessage);
        //启动服务
        intent = new Intent(this, TestService.class);
        startService(intent);
    }

    @Override
    protected void onDestroy() {
        //在合适的地方关闭服务
        stopService(intent);
        super.onDestroy();
    }
}
